<!DOCTYPE html>
<html>
<head>
    <meta name="layout" content="main2"/>
    <g:set var="entityName" value="${message(code: 'account?.label', default: 'account')}"/>
    <title>编辑客户</title>
</head>

<body>
<div class="main-body">
    <div class="page-wrapper">
        <!-- Page-header start -->
        <div class="page-header">
            <div class="page-header-title">
                <h4>编辑客户</h4>
            </div>

            <div class="page-header-breadcrumb">
                <ul class="breadcrumb-title">
                    <li class="breadcrumb-item">
                        <a href="/salesDashboard/index">
                            <i class="icofont icofont-home"></i>
                        </a>
                    </li>
                    <li class="breadcrumb-item">
                        <g:link controller="account" action="index">客户列表</g:link>
                    </li>
                    <li class="breadcrumb-item">编辑客户</li>
                </ul>
            </div>
        </div>
        <!-- Page-header end -->
        <!-- Page-body start -->
        <div class="page-body">
            <g:if test="${flash.message}">
                <div class="message alert alert-info" role="status">${flash.message}
                    <button type="button" class="close" data-dismiss="alert" aria-label="Close">
                        <span aria-hidden="true">×</span></button>
                </div>
            </g:if>
            <g:hasErrors bean="${this.account}">
                <ul class="errors" role="alert">
                    <g:eachError bean="${this.account}" var="error">
                        <li <g:if test="${error in org.springframework.validation.FieldError}">data-field-id="${error.field}"</g:if>><g:message
                                error="${error}"/></li>
                    </g:eachError>
                </ul>
            </g:hasErrors>
        <!-- Hover table card start -->
            <div class="card">
                <div class="card-header">
                    <h5>编辑客户</h5>

                    <div class="card-header-right">
                        <i class="icofont icofont-rounded-down"></i>
                    </div>
                </div>

                <div class="card-block">
                    <g:form resource="${this.account}" action="update" class="form-horizontal">
                        <div class="form-group row">
                            <label class="col-md-2 col-form-label is-required">客户名称</label>

                            <div class="col-md-3"><g:textField class="form-control" name="name" id="name"
                                                               value="${this.account?.name}"/></div>

                            <label class="col-md-2 col-form-label">曾用名</label>

                            <div class="col-md-3">

                                <g:textField class="form-control" name="alias" id="alias"
                                             value="${this.account?.alias}"/>
                            </div>
                        </div>

                        <div class="form-group row">

                            <label class="col-md-2 col-form-label is-required">类型</label>

                            <div class="col-md-3">
                                <g:select class="form-control" name="type" value="${this.account?.type?.id}"
                                          id="type" optionKey="id" optionValue="name"
                                          from="${com.next.AccountType.list()}"
                                          noSelection="${['': '请选择']}"/>

                            </div>

                            <label class="col-md-2 col-form-label">分级</label>

                            <div class="col-md-3">
                                <g:select class="form-control" name="level" value="${this.account?.level?.id}"
                                          id="level" optionKey="id" optionValue="name"
                                          from="${com.next.AccountLevel.list()}"
                                          noSelection="${['': '请选择']}"/>

                            </div>

                        </div>
                        <div class="form-group row">

                            <label class="col-md-2 col-form-label is-required">行业</label>

                            <div class="col-md-3">
                              <g:select class="form-control" name="industry" value="${this.account?.industry?.id}"
                                        id="industry" optionKey="id" optionValue="name"
                                        from="${com.next.Industry.list()}"
                                        noSelection="${['': '请选择']}"/>

                            </div>

                        </div>

                        <div class="form-group row">
                            <label class="col-md-2 col-form-label">雇员数量</label>

                            <div class="col-md-3">
                                <g:field type="number" class="form-control" name="numberOfEmployees"
                                         id="numberOfEmployees"
                                         value="${this.account?.numberOfEmployees}"/></div>
                            <label class="col-md-2 col-form-label">网站</label>

                            <div class="col-md-3">
                                <g:textField class="form-control" name="website" id="website"
                                             value="${this.account?.website}"/>
                            </div>

                        </div>

                        <div class="form-group row">
                            <label class="col-md-2 col-form-label">国家</label>

                            <div class="col-md-3">
                              <g:select class="form-control" name="country.id" value="${this.account?.country?.id}" optionValue="name" optionKey="id"
                                          from="${com.next.Country.list()}" noSelection="${['': '请选择']}"/>
                            </div>

                            <label class="col-md-2 col-form-label">城市</label>
                            <div class="col-md-3">
                                <g:select class="form-control" name="city.id" value="${this.account?.city?.id}" optionValue="name" optionKey="id"
                                          from="${com.next.City.list()}" noSelection="${['': '请选择']}"/>
                            </div>
                        </div>

                        <div class="form-group row">
                            <label class="col-md-2 col-form-label">注册资本货币类型</label>
                            <div class="col-md-3">
                                <g:select class="form-control" name="currencyType.id" value="${this.account?.currencyType?.id}" optionValue="name" optionKey="id"
                                          from="${com.next.CurrencyType.list()}" noSelection="${['': '请选择']}"/>
                            </div>

                            <label class="col-md-2 col-form-label is-required">注册资本</label>
                            <div class="col-md-3">
                              <div class="input-group">
                                <g:textField class="form-control" name="registeredCapital" id="registeredCapital"
                                           value="${this.account?.registeredCapital}"/>
                                  <span class="input-group-addon">元</span>
                              </div></div>
                        </div>

                        <div class="form-group row">
                            <label class="col-md-2 col-form-label">上级客户</label>

                            <div class="col-md-3">
                                <g:select class="form-control" name="parent.id" value="${this.account?.parent?.id}" optionValue="account" optionKey="accountId"
                                          from="${com.next.AccountTeam.findAllByUser(this?.user)}" noSelection="${['': '请选择']}"/>
                            </div>
                        </div>

                        <div class="form-group row">
                            <label class="col-md-2 col-form-label">启用</label>

                            <div class="col-md-3 border-checkbox-section">
                                <div class="border-checkbox-group border-checkbox-group-primary form-control-static">
                                    <g:checkBox class="border-checkbox" name="active" id="checkbox0"
                                                value="${this.account?.active}"/>
                                    <label class="border-checkbox-label" for="checkbox0"></label>
                                </div>

                            </div>
                            <g:if test="${this.enableTerritory}">
                                <label class="col-md-2 col-form-label">所处行业</label>

                                <div class="col-md-3">
                                    <g:select class="form-control" name="territory"
                                              value="${this.account?.territory?.id}"
                                              id="territory" optionKey="id" optionValue="name"
                                              from="${com.next.Territory.findAllByActive(true)}"
                                              noSelection="${['': '请选择']}"/></div>
                            </g:if>
                        </div>


                        <div class="form-group row">
                            <label class="col-md-2 col-form-label">所有者</label>

                            <div class="col-md-3">
                                <g:select class="form-control" name="user" value="${this.account?.user?.id}" id="level"
                                          optionKey="id" optionValue="fullName" from="${com.next.User.list()}"
                                          noSelection="${['': '请选择']}"/></div>
                        </div>

                        <div class="form-group row">
                            <label class="col-md-2 col-form-label">描述</label>

                            <div class="col-md-8">
                                <g:textArea rows="3" class="form-control" name="description" id="description"
                                            value="${this.account?.description}"/></div>
                        </div>


                        <div class="form-group row">
                            <div class="col-md-12">
                                <g:submitButton class="btn btn-info" name="update" value="保存"/></div>
                        </div>
                    </g:form>

                </div>
            </div>
            <!-- Hover table card end -->
        </div>

        <!-- Page-body end -->
    </div>
</div>

</body>
</html>
